Linux Server Basics: A Detailed Explanation of User and Permission Management
User and permission management in Linux is the core of system security and resource allocation. Users are the operating subjects, groups are used for unified permissions, and UID/GID are numerical identifiers (root UID=0). For user management: use `useradd` to create (add `-m` for home directory), `passwd` to set passwords, and `userdel -r` to delete. Switch identities with `su` and escalate privileges with `sudo` (requires adding to the sudo group). File permissions are represented by three sets of characters (rwx) for user/group/other permissions, set via numbers (e.g., 755) or symbols (e.g., u+x). Modify permissions with `chmod`, and change owners/groups with `chown`/`chgrp`. Directory permissions have special rules: execute permission (`x`) is required to enter, read permission (`r`) to view contents, and write permission (`w`) to create files. Special permissions include SUID (temporarily elevates program privileges, e.g., `passwd`), SGID (inherits group permissions for files), and SBIT (prevents accidental deletion, e.g., `/tmp`). `umask` controls default permissions for newly created files/directories (default 022, resulting in 644 for files and 755 for directories). Best practices: Follow the principle of least privilege, avoid routine operations as root, and regularly check high-risk permission files.
Read More